<%@page import="org.jeecgframework.web.util.StaticValue" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<t:datagrid fitColumns="true" name="myTaskList" queryMode="group" title="采购报价单列表" sortName="state" sortOrder="asc"
            actionUrl="cbsProcurementNoteController.do?getProcurementNodeApprovalList" idField="id" autoLoadData="true">
    <t:dgCol title="编号" width="120" field="id" hidden="true"></t:dgCol>
    <t:dgCol title="业务编码" width="120" field="busId" hidden="true" sortable="false"></t:dgCol>
    <t:dgCol title="编号" width="120" field="taskId" hidden="true"></t:dgCol>
    <t:dgCol title="采购单编号" width="120" field="procumentNo" query="true" align="center" ></t:dgCol>
    <t:dgCol title="报价单编号" width="120" field="quotationNum" query="true" align="center" ></t:dgCol>
    <t:dgCol title="设备序列号" width="300" field="sn"  align="center" ></t:dgCol>
    <t:dgCol title="机型" width="300" field="typeDesc"  align="center"></t:dgCol>
    <t:dgCol title="影院名称" width="300" field="cinemaName" query="true" align="center"></t:dgCol>
    <t:dgCol title="机构名称" width="300" field="departname"  align="center"></t:dgCol>
    <t:dgCol title="业务类型" width="120" field="defId"  hidden="true" query="false"></t:dgCol>
    <t:dgCol title="流程名称" width="120" field="processDefinitionName" align="center" ></t:dgCol>
    <t:dgCol title="申请人" width="120" field="createName" align="center"></t:dgCol>
    <t:dgCol title="申请时间" width="150" field="createDate" formatter="yyyy-MM-dd hh:mm" query="true"
             queryMode="group" align="center" ></t:dgCol>
    <t:dgCol title="状态" width="120" field="state" replace="待处理_0,处理中_1,审批中_5,已完成_2,已取消_3,已收款_6" query="true" align="center"></t:dgCol>
    <%--<t:dgCol title="节点名称" width="120" field="nodeName" align="center" sortable="false"/>--%>
    <t:dgCol title="处理时间" width="120" field="endTime" formatter="yyyy-MM-dd hh:mm" align="center"/>
    <t:dgCol title="实例ID" width="120" field="instId" hidden="true"></t:dgCol>
    <t:dgCol title="办理状态" width="120" field="handleStatus" replace="草稿_0,待办_1,已办_2" hidden="true"></t:dgCol>

    <t:dgCol title="操作" field="opt" width="200" align="center"></t:dgCol>
    <t:dgFunOpt title="办理" exp="handleStatus#eq#0"
                funname="goHandleWindow(taskId,id,defId,instId,processDefinitionName,handleStatus)"></t:dgFunOpt>
    <t:dgFunOpt title="办理" exp="handleStatus#eq#1"
                funname="goHandleWindow(taskId,id,defId,instId,processDefinitionName,handleStatus)"></t:dgFunOpt>
    <t:dgFunOpt title="查看" exp="handleStatus#eq#2"
                funname="goHandleWindow(taskId,id,defId,instId,processDefinitionName,handleStatus)"></t:dgFunOpt>
    <t:dgFunOpt title="收款" exp="state#eq#2"
                funname="gathering(id)"></t:dgFunOpt>
    <t:dgFunOpt title="取消"
                funname="cancle(id,procumentNo)"></t:dgFunOpt>
    <t:dgToolBar title="创建采购单" icon="icon-add" funname="addCreateTab" operationCode="createProcurement"/>
</t:datagrid>

<script type="text/javascript">
    $(function () {


        $("#myTaskListtb").find("input[name='createDate_begin']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").attr("id","createDate_begin").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'createDate_end\')}'});
        });
        $("#myTaskListtb").find("input[name='createDate_end']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").attr("id","createDate_end").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd',minDate:'#F{$dp.$D(\'createDate_begin\')}'});
        });

    })
    function goHandleWindow(taskId, busId, busType, instId, processDefinitionName, handleStatus) {
        var url;
        switch (busType) {
            case '<%=StaticValue.CBS_PART_FLOW_KEY %>':
                url = "cbsProcurementNoteController.do?goApproval&taskId=" + taskId + "&busId=" + busId + "&instId=" + instId;
                if (handleStatus == 0) {
                    url = "cbsProcurementNoteController.do?goAdd&id=" + busId;
                }
                break;
            case '<%=StaticValue.CBS_QUOTATION_FLOW_KEY%>':
                url = "cbsQuotationController.do?goApproval&taskId=" + taskId + "&busId=" + busId + "&instId=" + instId;
                break;
        }
        if (handleStatus == 2) {
            url += "&isDetail=" + handleStatus
        }
        openwindow(processDefinitionName + "办理", url, "myTaskList", "100%", "100%");
    }

    function addCreateTab() {
        addOneTab('创建采购单', 'cbsProcurementNoteController.do?goAdd', '');
    }
    function gathering(id) {
        createwindow("收款","cbsProcurementNoteController.do?goThering&id="+id, 400, 200);
    }
    function cancle(id,procumentNo){
        $.ajax({
            type: "post",
            dataType: "json",
            data: {"id": id,"procumentNo":procumentNo},
            url: "cbsProcurementNoteController.do?cancle",
            success: function (data) {
                if(data.success){
                    tip("操作成功");
                }
            }
        })
    }
</script>


